{include file="public/layout" /}
<body>
  <script type="text/javascript" src="__SKIN__/js/jquery.js?v={$version}"></script>
  <script src="__SKIN__/js/upgrade.js?v={$version}"></script>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md8">
        <div class="layui-row layui-col-space15">
          <div class="layui-col-md12">
            <div class="layui-card">
              <div class="layui-card-header">内容统计</div>

              <div class="layui-card-body">
                <div class="filter-tool" style="height: 60px">
                    <div class="layui-col-md6">
                      <input type="text" class="layui-input" id="date-picker" name="select_time">
                    </div>
                    <div class="layui-col-md2 pl">
                      <button class="layui-btn layui-btn-normal layui-btn-md tongji-btn">搜索</button>
                    </div>
                </div>
                <div class="layui-carousel layadmin-carousel layadmin-backlog">
                  <div carousel-item>
                    <ul class="layui-row layui-col-space10" id="tongji-nav">
                      {volist name='$contentTotal' id='vo' length='7'}
                      {notempty name="$vo.is_menu"}
                      <li class="layui-col-xs4 layui-col-md3">
                        <a lay-href="{:url($vo.controller.'/'.$vo.action, $vo.vars)}" lay-text="{$vo.laytext}" class="layadmin-backlog-body">
                          <h3>{$vo.title}</h3>
                          <p><cite>{$vo.total|default='0'}</cite></p>
                        </a>
                      </li>
                      {/notempty}
                      {/volist}
                      <li class="layui-col-xs4 layui-col-md3">
                        <a href="javascript:;" id="contentTotalAdd" class="layadmin-backlog-body">
                          <h3>添加统计</h3>
                          <p><cite><i style="font-size: 30px" class="layui-icon layui-icon-add-1"></i></cite></p>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="layui-col-md4">
        <div class="layui-card">
          <div class="layui-card-header">版本信息</div>
          <div class="layui-card-body layui-text">
            <table class="layui-table mt8 mb8">
              <colgroup>
                <col width="100">
                <col>
              </colgroup>
              <tbody>
                <tr>
                  <td>系统更新</td>
                  <td id="td_upgrade_msg">
                    <div id="upgrade_filelist" style="display:none;"></div> 
                    <div id="upgrade_intro" style="display:none;"></div> 
                    <div id="upgrade_notice" style="display:none;"></div> 
                    <a href="javascript:void(0);" id="a_upgrade" data-version="" data-max_version="" data-iframe="workspace" title="" data-tips_url="{:url('Upgrade/setPopupUpgrade')}" data-upgrade_url="{:url('Upgrade/OneKeyUpgrade')}" data-check_authority="{:url('Upgrade/check_authority')}">正在版本检测中……</a>
                  </td>
                </tr>
                <tr>
                  <td>当前版本</td>
                  <td>
                    {$sys_info.curent_version|default='v1.0.0'}
                    {notempty name="$is_think_business"}
                    <a href="http://www.ejucms.com/shengjihuizong/" target="_blank" style="padding-left: 15px;">更新日志</a>
                    {/notempty}
                 </td>
                </tr>
                <tr>
                  <td>程序名称</td>
                  <td>{$sys_info.web_name|default='易居cms房产网站建设系统'}</td>
                </tr>
                <tr>
                  <td>商用许可</td>
                  {notempty name="$is_think_business"}
                  <td style="padding-bottom: 0;">
                    <div class="layui-btn-container">
                      <a href="http://www.ejucms.com/baojiafuwu/" target="_blank" class="layui-btn layui-btn-danger layui-btn layui-btn-sm">购买授权</a>
                      <a data-url="{:url('Index/authortoken')}" href="javascript:void(0);" id="check_authortoken" class="layui-btn layui-btn layui-btn-sm">立即校验</a>
                    </div>
                  </td>
                  {else /}
                  <td>正版软件</td>
                  {/notempty}
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">快捷导航</div>
          <div class="layui-card-body">
            <div class="console-menu">
               <ul class="layui-row layui-col-space10">
                {volist name='$quickMenu' id='vo'}
                 {notempty name="$vo.is_menu"}
                  <li class="layui-col-xs3 layui-col-md2">
                    <a lay-href="{:url($vo.controller.'/'.$vo.action, $vo.vars)}" lay-text="{$vo.laytext}">
                      <i class="layui-icon"><cite>{$vo.title}</cite></i>
                    </a>
                  </li>
                 {/notempty}
                {/volist}
                <li class="layui-col-xs3 layui-col-md2">
                    <a href="javascript:void(0);" id="quickMenuAdd">
                      <cite><i style="font-size: 30px" class="layui-icon layui-icon-add-1"></i></cite>
                    </a>
                  </li>
                </ul>
             </div> 
          </div>
        </div>
      </div>
    </div>
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md8">
        <div class="layui-card">
          <div class="layui-tab layui-tab-brief layadmin-latestData">
            <ul class="layui-tab-title">
              <li class="layui-this">最新楼盘</li>
              <li>最新楼市</li>
            </ul>
            <div class="layui-tab-content">
              <div class="layui-tab-item layui-show">
                <table id="table-index-xinfang" ></table>
                <a class="layui-btn layui-btn-sm mt10" lay-text="内容管理" lay-href="{:url('Archives/index_archives',['channel'=>9])}">查看更多</a>
              </div>
              <div class="layui-tab-item">
                <table id="table-index-article"></table>
                <a class="layui-btn layui-btn-sm mt10"  lay-text="内容管理" lay-href="{:url('Archives/index_archives',['channel'=>1])}">查看更多</a>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-col-md4">
        <div class="layui-card">
          <div class="layui-card-header">服务器信息</div>
          <div class="layui-card-body layui-text">
            <table class="layui-table">
              <colgroup>
              <col width="150">
              <col>
              </colgroup>
              <tbody>
              <tr>
                <td>服务器操作系统：</td>
                <td>{$sys_info.os}</td>
              </tr>
              <tr>
                <td>服务器域名/IP：</td>
                <td>{$sys_info.domain} / [ {$sys_info.ip} ]</td>
              </tr>
              <tr>
                <td>服务器环境：</td>
                <td>{$sys_info.web_server}</td>
              </tr>
              <tr>
                <td>PHP 版本：</td>
                <td>{$sys_info.phpv}</td>
              </tr>
              <tr>
                <td>Mysql 版本：</td>
                <td>{$sys_info.mysql_version}</td>
              </tr>
              <tr>
                <td>GD 版本：</td>
                <td>{$sys_info.gdinfo}</td>
              </tr>
              <tr>
                <td>文件上传限制：</td>
                <td>{$sys_info.fileupload}</td>
              </tr>
              <tr>
                <td>最大占用内存：</td>
                <td>{$sys_info.memory_limit}</td>
              </tr>
              <tr>
                <td>POST限制：</td>
                <td>{$sys_info.postsize|default='unknown'}</td>
              </tr>
              <tr>
                <td>最大执行时间：</td>
                <td>{$sys_info.max_ex_time}</td>
              </tr>
              <tr>
                <td>Zip支持：</td>
                <td>{$sys_info.zip}</td>
              </tr>
              <tr>
                <td>Zlib支持：</td>
                <td>{$sys_info.zlib}</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script type="text/javascript">
    layui.config({
      base: '__SKIN__/' //静态资源所在路径
      ,version: '{$version}'
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['index', 'console','table','laydate'], function(){
      var $ = layui.$
      // ,device = layui.device()
      ,layer = layui.layer
      ,table = layui.table;
      //时间插件
      var laydate = layui.laydate;

      //执行一个laydate实例
      laydate.render({
        elem: '#date-picker', //指定元素
        type:"datetime",
        range: true
      });
      $(".tongji-btn").on('click',function () {
        var val = $("#date-picker").val();
        $.get("/login.php?m=admin&c=index&a=welcome",
                {
                  datetime:val,
                  do:"tongji"
                },
                function (res) {
                  if(res.code===1){
                      var html="";
                      for(var i in res.data){
                        $vo = res.data[i]
                        $var = "";
                        for(var ii in $vo.vars){
                          $var+="&"+ii+"="+$vo.vars[ii];
                        }
                      html+="<li class='layui-col-xs4 layui-col-md3'><a class='layui-col-xs4 layui-col-md3'>"+
                              "<a lay-href='/login.php?m=admin&c='"
                              +$vo.controller +"&a=" +$vo.action +$var
                              +"' lay-text='"+$vo.laytext
                              +"' class='layadmin-backlog-body'>"
                              +"<h3>"+$vo.title+"</h3>"
                              +"<p><cite>"+$vo.total*1+"</cite></p>"
                              +"</a></li>"
                      }
                      html+="<li class='layui-col-xs4 layui-col-md3'>"
                              +"<a href=\"javascript:;\" id=\"contentTotalAdd\" class=\"layadmin-backlog-body\">"
                              +"<h3>添加统计</h3>"
                              +"<p><cite><i style='font-size: 30px' class='layui-icon layui-icon-add-1'></i></cite></p>"
                              +"</a></li>"
                      $("#tongji-nav").html(html)
                  }
        });
      })
      table.render({
          elem: '#table-index-xinfang'
          ,url: "{:url('Xinfang/ajax_get_list')}" //模拟接口
          ,page:false
          ,cols: [[
              {field: 'aid', title: 'ID', width:80, sort: true, fixed: 'left'}
              ,{field: 'title', title: '标题',templet: '<div><a lay-text="内容管理" lay-href="{{d.lay_href}}" class="layui-table-link ">{{ d.title }}</div>'}
//              ,{field: 'title', title: '标题',templet: '<div><a href="{{ d.arcurl }}" target="_blank" class="layui-table-link">{{ d.title }}</div>'}
              ,{field: 'typename', title: '所属栏目', width: 120, sort: true}
              ,{field: 'click', title: '浏览量', width: 80, sort: true}
          ]]
      });

      table.render({
          elem: '#table-index-article'
          ,url: "{:url('Article/ajax_get_list')}" //模拟接口
          ,page:false
          ,cols: [[
              {field: 'aid', title: 'ID', width:80, sort: true, fixed: 'left'}
                  ,{field: 'title', title: '标题',templet: '<div><a  lay-text="内容管理" lay-href="{{d.lay_href}}" class="layui-table-link ">{{ d.title }}</div>'}
//              ,{field: 'title', title: '标题',templet: '<div><a href="{{ d.arcurl }}" target="_blank" class="layui-table-link">{{ d.title }}</div>'}
              ,{field: 'typename', title: '所属栏目', width: 120, sort: true}
              ,{field: 'click', title: '浏览量', width: 80, sort: true}
          ]]
      });

      check_upgrade_version(); // 版本检测更新弹窗
      $.get("{:url('Ajax/welcome_handle', ['_ajax'=>1])}"); // 进入欢迎页面需要异步处理的业务
      checkInlet(); // 自动检测隐藏index.php
      
      // 新增内容统计
      $('#contentTotalAdd').click(function(){
        //iframe窗
        var iframes = layer.open({
            type: 2,
            title: '内容统计管理',
            fixed: true, //不固定
            shadeClose: false,
            shade: 0.3,
            // maxmin: false, //开启最大化最小化按钮
            area: ['550px', '400px'],
            content: "{:url('Index/ajax_content_total')}"
        });
      });

      // 新增快捷导航
      $('#quickMenuAdd').click(function(){
        //iframe窗
        var iframes = layer.open({
            type: 2,
            title: '快捷导航管理',
            fixed: true, //不固定
            shadeClose: false,
            shade: 0.3,
            // maxmin: false, //开启最大化最小化按钮
            area: ['550px', '400px'],
            content: "{:url('Index/ajax_quickmenu')}"
        });
      });

      // 功能面板 - 更多功能
      // $('.moreFunction').click(function(){
      //   var othis = $('.layadmin-shortcut');
      //   othis.find('div.layui-carousel-ind ul li').each(function(index,element){
      //     if (1 == index) {
      //       var trigger = (device.ios || device.android) ? 'click' : 'mouseover';
      //       $(element).trigger(trigger);
      //     }
      //   });
      // });

      $('#check_authortoken').click(function(){
          var load = layer_loading();
          $.ajax({
              type : "GET",
              url  : $(this).data('url'),
              data : {_ajax:1},
              dataType : "JSON",
              success: function(res) {
                  layer.close(load); //关闭loading
                  if (1 == res.code) {
                      layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                          top.window.location.reload();
                      });
                  }else{
                      showErrorMsg(res.msg);
                  }
              }
              ,error: function(e){
                  layer.close(load); //关闭loading
                  showErrorAlert();
              }
          }); 
      });

      // 自动检测隐藏index.php
      function checkInlet() {
          layer.open({
              type: 2,
              title: false,
              area: ['0px', '0px'],
              shade: 0.0,
              closeBtn: 0,
              shadeClose: true,
              content: '//{$Request.host}__ROOT_DIR__/api/Rewrite/setInlet.html',
              success: function(layero, index){
                  layer.close(index);
                  var body = layer.getChildFrame('body', index);
                  var content = body.html();
                  if (content.indexOf("Congratulations on passing") == -1)
                  {
                      $.ajax({
                          type : "POST",
                          url  : "__ROOT_DIR__/index.php?m=api&c=Rewrite&a=setInlet&_ajax=1",
                          data : {seo_inlet:0},
                          dataType : "JSON",
                          success: function(res) {

                          }
                      }); 
                  }
              }
          });
      }

      function check_upgrade_version(){
          $.ajax({
              type : "GET",
              url  : "{:url('Ajax/check_upgrade_version')}",
              data : {_ajax:1},
              dataType : "JSON",
              success: function(res) {
                  if (1 == res.code) {
                      if (2 == res.data.code) {
                          $('#upgrade_filelist').html(res.data.msg.upgrade);
                          $('#upgrade_intro').html(res.data.msg.intro);
                          $('#upgrade_notice').html(res.data.msg.notice);
                          $('#a_upgrade').attr('data-version', res.data.msg.key_num)
                          .attr('data-max_version', res.data.msg.max_version)
                          .attr('title', res.data.msg.tips);
                          $('#a_upgrade').html('检测到新版本'+res.data.msg.key_num+'[点击查看]').css('color', '#F00');

                          {if condition="1 == $web_show_popup_upgrade AND (0 >= $Think.session.admin_info.role_id OR 1 == $Think.session.admin_info.auth_role_info.online_update)"}
                              btn_upgrade($("#a_upgrade"), 1);
                          {/if}
                      } else {
                          $('#td_upgrade_msg').html(res.data.msg);
                      }
                  }
              }
          }); 
      }
    });

  </script>
{include file="public/footer" /}

